package com.jcwx.game.login;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.jcwx.game.domain.LoginPassportInfo;
import com.jcwx.game.domain.RegisterInfo;
import com.jcwx.game.util.BocHttpClient;

/**
 * 登录中转中心
 * @author csp
 *
 */
public class LoginPassport {
	
	
	
	public LoginPassportInfo LoginPassportInfo(RegisterInfo registerInfo){
		
		String url = "http://192.168.1.250:8880/api01/user/login.action";
		Map<String, String> params = new HashMap<String, String>();
		params.put("uid",String.valueOf(registerInfo.getUid()));
		params.put("pw", registerInfo.getPwsource());
		String jsonObject = "";
		try {
			jsonObject = BocHttpClient.sendPost(url, params);
			System.out.println(jsonObject);
		} catch (Exception e) {
			e.printStackTrace();
		}

		JSONObject json = JSONObject.parseObject(jsonObject);
		LoginPassportInfo loginPassportInfo=new LoginPassportInfo();
		loginPassportInfo.setCode(json.getInteger("code"));
		loginPassportInfo.setLoginNum(json.getString("loginNum"));
		loginPassportInfo.setMsg(json.getString("msg"));
		loginPassportInfo.setPwSafe(json.getBooleanValue("pwSafe"));
		loginPassportInfo.setToken(json.getString("token"));
		loginPassportInfo.setBindEmail(json.getBooleanValue("isBindEmail"));
		return loginPassportInfo;
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		LoginPassport loginPassport=new LoginPassport();

		LoginPassportInfo loginPassportInfo= loginPassport.LoginPassportInfo(null);
		System.out.println(loginPassportInfo.getToken());
		
	}

}
